﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">FocusFirstControl</title>
  <keywords>
    <keyword translate="true">Behaviors</keyword>
    <keyword translate="true">Commands</keyword>
    <keyword translate="true">Events</keyword>
    <keyword translate="true">Focus</keyword>
    <keyword translate="true">FocusFirstControl</keyword>
    <keyword translate="true">MVVM</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">FocusFirstControl</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Notes" style="font-style:normal;" translate="true">The </text><link displaytype="text" defaultstyle="true" type="topiclink" href="Behaviors_Focus" styleclass="Notes" style="font-style:normal;" translate="true">Focus behavior</link><text styleclass="Notes" style="font-style:normal;" translate="true"> is very powerful, but sometimes you just need to focus the first control on a window or control. This can be done by using the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_Windows_Interactivity_FocusFirstControl" styleclass="Notes" style="font-style:normal;" translate="true">FocusFirstControl</link><text styleclass="Notes" style="font-style:normal;" translate="true"> behavior instead. This behavior will focus the first control on a window or control and has only one property: </text><text styleclass="Notes" style="font-style:italic;" translate="true">FocusParentFirst</text><text styleclass="Notes" style="font-style:normal;" translate="true">. </text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Add the following XML namespaces:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">xmlns:i=&quot;clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity&quot;</text><br/><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">xmlns:catel=&quot;http://catel.codeplex.com&quot;</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Focus when the control is loaded</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The easiest and default method is to focus the first control. The parent is also focused by default (just in case if it doesn&apos;t have any focus):</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&lt;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">Window</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> ...&gt;</text><br/><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true"> &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&lt;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">i:Interaction.Behaviors</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&gt;</text><br/><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true"> &#160; &#160; &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&lt;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">catel:FocusFirstcontrol</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> /&gt;</text><br/><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true"> &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&lt;/</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">i:Interaction.Behaviors</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&gt;</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&lt;/</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">Window</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&gt;</text></para>
  </body>
</topic>
